<?php
FLEA::loadClass('TMIS_TableDataGateway');
class Model_Sample_Kucun extends TMIS_TableDataGateway {
    var $tableName = "sample_kucun";
    var $primaryKey = "id";

    var $needCreateLog = false;// 需要打日志则加此参数
    public function getKucun($param){
        //查找当前实际库存
        $sql = "SELECT sum(cnt) as cnt from sample_kucun where 1";
        if($param['productId']){
            $sql .= " and productId = '{$param['productId']}'";
        }
        if($param['type']){
            $sql .= " and type = '{$param['type']}'";
        }
        if($param['proDesc']){
            $sql .= " and proDesc = '{$param['proDesc']}'";
        }
        if($param['kuweiId']){
            $sql .= " and kuweiId = '{$param['kuweiId']}'";
        }
        if($param['code']){
            $sql .= " and code = '{$param['code']}'";
        }
        if($param['gexing']){
            $sql .= " and gexing = '{$param['gexing']}'";
        }
        if($param['tanli']){
            $sql .= " and tanli = '{$param['tanli']}'";
        }
        if($param['zuzhi']){
            $sql .= " and zuzhi = '{$param['zuzhi']}'";
        }


        $tmp = $this->findBySql($sql);
        $cnt = $tmp[0]['cnt'];

        return $cnt;
    }
}
?>